<template>
	<view>
		<view>
			<view class="" style="display: flex; margin-top: 40rpx; padding: 40rpx 60rpx">
				<view class="">
					<image style="width: 200rpx; height: 250rpx;" @click="clickImg(studentInfo.stuPhoto)"
						:src="studentInfo.stuPhoto" mode=""></image>
				</view>
				<view style="margin-left: 80rpx;display: flex; flex-direction: column; justify-content: space-around;">
					<view style="display: flex; width: 400rpx; margin-top: 8rpx;">
						<view class="character">宿舍号：</view>
						<view class="character">{{studentInfo.dormitoryName}}</view>
					</view>
					<view style="display: flex; width: 400rpx; margin-top: 8rpx;">
						<view class="character">姓名：</view>
						<view class="character">{{studentInfo.studentName}}</view>
					</view>
					<view style="display: flex; width: 400rpx; margin-top: 8rpx;">
						<view class="character">性别：</view>
						<view class="character">{{studentInfo.sex == 0 ?"男" :"女"}}</view>
					</view>
					<view style="display: flex; width: 400rpx; margin-top: 8rpx;">
						<view class="character">班级：</view>
						<view class="character">{{studentInfo.className}}</view>
					</view>
					<view style="display: flex; width: 400rpx; margin-top:8rpx;" v-if="this.userInfo != '宿管老师'">
						<view class="character">联系电话：</view>
						<view style="display: flex; justify-content: space-between;">
							<view class="character">{{studentInfo.phone}} </view>

						</view>
					</view>
					<view style="display: flex; margin-top: 8rpx;">
						<view class="character">班主任：</view>
						<view class="character">{{studentInfo.teacherName}}</view>
					</view>
					<view style="display: flex; margin-top: 8rpx;">
						<view class="character">班主任电话：</view>
						<view class="character">{{studentInfo.teacherPhone}}</view>

					</view>

				</view>
			</view>
			<view style="padding:40rpx; font-size: 36rpx;">处理记录</view>
			<view class="bigBox">
				<view class="box" style="display: flex; align-items: center; justify-content: center;;"
					v-for="item in recordList" :key="item.id">
					<view class="card" v-if="item.type ==1">
						<view class="">
							<view class="ftColor">{{item.createBy}}电话联系学生</view>
							<view style="margin-top: 20rpx;">{{item.result}}</view>
						</view>
						<view class="" style="display: flex; flex-direction: column; justify-content: space-between;">
							<view style="color: #aaa;">{{item.createTime}}</view>
						</view>
					</view>
					<view class="card" v-if="item.type ==2">
						<view class="">
							<view class="ftColor">{{item.createBy}}宿舍管理员提交</view>
							<view style="margin-top: 20rpx;">{{item.result}}</view>
						</view>
						<view class="" style="display: flex; flex-direction: column; justify-content: space-between;">
							<view style="color: #aaa;">{{item.createTime}}</view>
						</view>
					</view>
					<view class="card" v-if="item.type ==3">
						<view class="">
							<view class="ftColor">{{item.createBy}}提交给班主任处理</view>
							<view style="margin-top: 20rpx;">{{item.result}}</view>
						</view>
						<view class="" style="display: flex; flex-direction: column; justify-content: space-between;">
							<view style="color: #aaa;">{{item.createTime}}</view>

						</view>
					</view>
					<view class="card" v-if="item.type ==4">
						<view class="">
							<view class="ftColor">{{item.createBy}}班主任处理结果</view>
							<view style="margin-top: 20rpx;">{{item.result}}</view>
						</view>
						<view class="" style="display: flex; flex-direction: column; justify-content: space-between;">
							<view style="color: #aaa;">{{item.createTime}}</view>

						</view>
					</view>
					<view class="card" v-if="item.type ==5">
						<view class="">
							<view class="ftColor">{{item.createBy}}提交给部门经理处理</view>
							<view style="margin-top: 20rpx;">{{item.result}}</view>
						</view>
						<view class="" style="display: flex; flex-direction: column; justify-content: space-between;">
							<view style="color: #aaa;">{{item.createTime}}</view>

						</view>
					</view>
					<view class="card" v-if="item.type ==6">
						<view class="">
							<view class="ftColor">{{item.createBy}}部门经理处理结果</view>
							<view style="margin-top: 20rpx;">{{item.result}}</view>
						</view>
						<view class="" style="display: flex; flex-direction: column; justify-content: space-between;">
							<view style="color: #aaa;">{{item.createTime}}</view>
						</view>
					</view>
					<view class="card" v-if="item.type ==7">
						<view class="">
							<view class="ftColor">{{item.createBy}}宿管反馈结束</view>
							<view style="margin-top: 20rpx;">{{item.result}}</view>
						</view>
						<view class="" style="display: flex; flex-direction: column; justify-content: space-between;">
							<view style="color: #aaa;">{{item.createTime}}</view>
						</view>
					</view>
					<view class="card" v-if="item.type ==8">
						<view class="">
							<view class="ftColor">{{item.createBy}}宿管反馈未归寝</view>
							<view style="margin-top: 20rpx;">{{item.result}}</view>
						</view>
						<view class="" style="display: flex; flex-direction: column; justify-content: space-between;">
							<view style="color: #aaa;">{{item.createTime}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import taskNotReturned from "@/api/modules/taskNotReturned.js"
	import managementTeacher from "@/api/modules/managementTeacher.js"
	import teacherClass from "@/api/modules/teachClass.js"
	import {
		parseTime
	} from "@/utils/date.js"
	export default {
		data() {
			return {
				bzrUrl: "/pages_main/managementTeacher/taskNotReturned/taskNotReturned",
				topName: "处理",
				userName: "",
				studentInfo: {},
				notReturnedDate: "",
				reason: "",
				buildNo: "",
				date: "",
				processContent: "",
				recordList: [],
				studentId: "",
				flag: "",
				applyDesc: "",
				formData: {},
				userInfo: "",
			}
		},
		methods: {
			clickImg(img) {
				uni.previewImage({
					urls: [img], //需要预览的图片http链接列表，多张的时候，url直接写在后面就行了
					current: '', // 当前显示图片的http链接，默认是第一个
					success: function(res) {},
					fail: function(res) {},
					complete: function(res) {},
				})
			},
			formatTen(num) {
				return num > 9 ? (num + "") : ("0" + num);
			},
			formatDate(date) {
				var date = new Date(date)
				var year = date.getFullYear();
				var month = date.getMonth() + 1;
				var day = date.getDate();
				var hour = date.getHours();
				var minute = date.getMinutes();
				var second = date.getSeconds();
				return year + "-" + this.formatTen(month) + "-" + this.formatTen(day) + " " + this.formatTen(hour) + ":" +
					this.formatTen(
						minute) + ":" + this.formatTen(second);
			},
			getRecords(date, id) {
				managementTeacher.getTrackRecordByDateAndStuId(date, id).then(res => {
					this.recordList = res.data
					this.recordList.forEach(item => {
						item.createTime = parseTime(new Date(item.createTime).getTime())
						console.log(item.createTime)
					})
					console.log(this.recordList)
				})
			},

			toUncheck() {
				uni.navigateTo({
					url: "/pages_main/managementTeacher/unCheckedStudents/unCheckedStudents"
				})
			},

		},
		onLoad(options) {
			this.userInfo = uni.getStorageSync("userInfo")
			this.userName = uni.getStorageSync("userName")
			if (options.flag == 9) {
				options = JSON.parse(options.item)
				console.log(options)
				this.date = options.notRetrunedDate
				this.bzrUrl = `/pages_main/managementTeacher/notReturnBed/notReturnBed`
				taskNotReturned.getStudentById(options.studentId).then(res => {
					this.studentInfo = res.data
				})
				this.studentId = options.studentId
				this.getRecords(this.date, this.studentId)
			} else if (options.flag == 20) {
				this.bzrUrl = `/pages_main/managementTeacher/unCheckedStudents/unCheckedStudents?current=${options.current}`
				options = JSON.parse(options.item)
				this.date = options.businessData.notRetrunedDate
				taskNotReturned.getStudentById(options.businessData.studentId).then(res => {
					this.studentInfo = res.data
				})
				this.studentId = options.businessData.studentId
				this.getRecords(this.date, this.studentId)
			} else {
				options = JSON.parse(options.item)
				console.log(options)
				this.date = options.businessData.notRetrunedDate
				this.bzrUrl = `/pages_main/managementTeacher/taskNotReturned/taskNotReturned`
				taskNotReturned.getStudentById(options.businessData.studentId).then(res => {
					this.studentInfo = res.data
				})
				this.studentId = options.businessData.studentId
				this.getRecords(this.date, this.studentId)
			}
		}
	}
</script>

<style scoped>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.indexContent {
		height: 100vh;

	}

	.character {
		font-size: 24rpx;
		/* color: #979999; */
		color: #000;
	}

	.popup-content {
		/* @include flex; */
		align-items: center;
		justify-content: center;
		padding: 15px;
		height: 20vh;
		background-color: #fff;
		width: 500rpx;
	}

	.card {
		width: 90%;
		/* border: 1rpx #000 solid; */
		padding: 30rpx 10rpx 10rpx 10rpx;
		display: flex;
		font-size: 24rpx;
		justify-content: space-between;
	}

	.ftColor {
		color: #3333d3;
	}

	.cancel {
		width: 35%;
		background-color: #a0a0a0;
		padding: 20rpx;
		text-align: center;
		border-radius: 10rpx;
		color: #fff;
		font-size: 40rpx;
		box-shadow: rgba(0, 0, 0, 0.08) 0px 0px 3px 1px;
	}

	.tijiao {
		width: 35%;
		background-color: #ff009a;
		padding: 20rpx;
		text-align: center;
		border-radius: 10rpx;
		color: #fff;
		font-size: 40rpx;
		box-shadow: rgba(0, 0, 0, 0.08) 0px 0px 3px 1px;
	}

	.box {
		margin-top: 20rpx;
		border-top: 1rpx solid #ddd;
	}

	.box:nth-child(1) {
		margin-top: -20rpx;
		border-top: none;
	}
</style>